package org.example.controller;

import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.example.config.RocketMQConfigProperties;
import org.example.utils.TmpTools;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Date;

@Slf4j
@RestController
@RequestMapping("/order")
public class OrderController {

    @Autowired
    private RocketMQTemplate rocketMQTemplate;

    @Autowired
    private RocketMQConfigProperties prop;

    @RequestMapping("/send")
    public String send() {
        for(int i = 0; i < 100; i++) {
            rocketMQTemplate.syncSendOrderly(prop.getTopic().get("order"), "我是order-"+TmpTools.timeToString(new Date().getTime())+"-"+i, "商品ID");
        }
        return "ok";
    }
}
